﻿using DX_Recognize.Common;
using DX_Recognize.Utils;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Xml.Linq;
using ZwSoft.ZwCAD.DatabaseServices;
using ZwSoft.ZwCAD.GraphicsSystem;
using ZwSoft.ZwCAD.Runtime;
using static DX_Recognize.Utils.ConvertUtils;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;

//中间存储 临时变量
namespace DX_Recognize.Entitys
{
    public static class UserPromptErrorType
    {
        public static string SelectCollectionNull = "选择集为空 操作取消!\n";
        public static string NoTopViewCenterLine = "投影图没有中心线 请绘制!";
        public static string ViewPlateWidthError = "组装图与投影图宽度不一致! 请校验更正!\n";
        public static string FangtieRefNumError = "组装图与投影图方铁线段数量不一致! 请校验更正!\n";
        public static string GPNotuibanError = "没有推板 无法推算导柱! 请校验更正!\n";
        public static string TooBigMouldSize = "超过目前标准模架尺寸! 请校验更正!\n";
        public static string GPERPRecognizeError = "导柱和拉杆同时出现在水口面板上 无法精确识别!\n";
        public static string TwoViewCenterNoError = "投影图 组装图坐标没有映射对齐!\n";
        //public static string CanNotRPannelScrew = "无法识别出面板螺丝!\n";
        //public static string CanNotFangtieScrew = "无法识别出方铁螺丝!\n";
        public static string CanNotRFrameBeforeSelectTV = "没有框选投影图精框直线 无法进行精框识别!\n";
        public static string CanNotSelectFrameLine = "没有框选投影图精框线 无法进行精框识别!\n";
        public static string FrameCanNotSelectLine = "没有选中竖线或横线 无法进行精框识别!\n";
        public static string FrameDepthNotVLine = "组装图加工框需要选择竖直方向的线段 请重新选取!\n";
        public static string OperBoardError = "请重置数据后再进行+-板操作!\n";
        public static string CannotDelBoardError = "非法-板操作!\n";
        public static string CustomerLineNumError = "识别出错 请检查对应花式与客图!\n";
        public static string ExitItemZeroNum = "存在零件数量为0的数据 请重新核对后上传!\n";
        public static string ExitItemZeroLength = "存在零件长度为0的数据 请重新核对后上传!\n";
        public static string NullFilePathError = "当前空文档!\n";
        public static string SaveUploadRecordError = "保存上传记录失败!\n";
        public static string SearchUploadRecordError = "查询上传记录失败!\n";
        public static string uploadToErpError = "上传失败 请联系开发人员!\n";
        public static string netWorkError = "网络故障 请检查网络!\n";
        public static string uploadToErpFindErpError = "上传失败 请联系ERP人员!\n";
        public static string uploadFilePathError = "查找不到上传记录图纸的位置 请检查!\n";
        public static string processDataError = "上传数据处理失败 请联系开发人员!\n";
        public static string businessError = "业务处理失败 请联系开发人员!\n";
    }

    public static class UserPromptType
    {
        public static string UserSelectModeNum = "请框选模号!\n";
        public static string UserSelectTopViewFrameLine = "请在投影图中选中一条精框直线! \n";
        public static string UserSelectAFrameLine = "请在组装图中选中一条精框深度线!\n";
        public static string SuccessRAssembly = "组装图识别完毕!\n";
        public static string SuceessRTopView = "投影图识别完毕 请框选组装图!\n";
        public static string SelectTVFrameLine = "已选中投影图精框!\n";
        public static string SelectAFrameDepthLine = "已选中组装图精框深度线!\n";
        public static string AMUploadToErp = "加工数据已上传ERP 请勿重复上传!\n";
        public static string MaxTimeUploadFailTig = "上传ERP失败 已暂存至临时记录 请从临时记录重新上传该数据!";
    }

   //吊令补齐模式
    public enum PullingPushType
    {
        None = -1,
        AsUsual,//照常
        StandardSup, //标准
        wholeRep //整套
    }

    // 方铁组合类型
    public enum FangtieType
    {
        None,//未判定
        Two_SS, //2方铁直身
        Two_LS_RIn,//2方铁 左直身 右内缩
        Two_LS_ROut,//2方铁 左直身 右凸
        Two_RS_LIn,//2方铁 右直身 左内缩
        Two_RS_LOut,//2方铁 右直身 左凸
        Two_NS, //2方铁 左右都内缩
        Three_SS_C,//3方铁 2直身 1中间
        Three_LROut_C,//3方铁 2凸 1中间
        Three_LS_ROut_C,//3方铁 左直身 右凸
        Three_RS_LOut_C,//3方铁 右直身 左凸
        Three_LRIn_C,//3方铁 左右都内缩 1中间
        Three_LS_RIn_C,//3方铁 左直身 右内缩
        Three_RS_LIn_C,//3方铁 右直身 左内缩     
    }

    //识别模架 基础 
    public static class MoldBaseShare
    {
        public static MoldTVInfo tvInfo = new MoldTVInfo();
        //板宽
        public static double Width { get; set; }
        //板长
        public static double Length { get; set; }
    }

    public class MoldTVInfo
    {
        public Boolean canCalF { get; set; } = false;

        public  double TVMaxY { get; set; }
        public  double TVMinY { get; set; }
    }

    // 横向  首尾 Transverse head and tail
    public class FullInfoLine
    {
        //第一个坐标
        public MixedCAD_Point StartPoint { get; set; } = new MixedCAD_Point();
        //最后一个坐标
        public MixedCAD_Point EndPoint { get; set; } = new MixedCAD_Point();
        //推算模型过程中 实际使用的点坐标
        public CAD_Point UseStartPoint { get; set; } = new CAD_Point();
        public CAD_Point UseEndPoint { get; set; } = new CAD_Point();
        //实际长度
        public double RealLength { get; set; }
        //线段类型 
        public CADLineType LineType { get; set; }
        //主导 线颜色信息
        public CAD_Color MainColorInfo { get; set; } = new CAD_Color();
        //主导 图层
        public String MainLayer { get; set; }
    }

    //候选线的混合信息
    public class CandidateMixInfo
    {
        //对应的各个板还有相关线段的信息
        public List<CandidateBLIAboutInfo> eachBoardInfo { get; set; } = new List<CandidateBLIAboutInfo>();
        public List<FullInfoLine> GetAllBoardLineList()
        {
            List<FullInfoLine> res = new List<FullInfoLine>();
            if (eachBoardInfo.Count > 0)
                eachBoardInfo.ForEach(item => res.AddRange(item.AboutLList));
            if (res.Count > 0)
                res = res.OrderByDescending(item => item.StartPoint.CustomerPoint.Y).ToList();
            return res;
        }
    }

    //客图 CAD 投影图 全部的图元信息
    public class TopViewCADInfo
    {
        public List<MixedCAD_Line> TVLList { get; set; } = new List<MixedCAD_Line>();
        public List<MixedCAD_Circle> TVCirList { get; set; } = new List<MixedCAD_Circle>();
        public List<MixedCAD_Text> TVTextList { get; set; } = new List<MixedCAD_Text>();
       // public List<MixedCAD_Line> TVCLList { get; set; } = new List<MixedCAD_Line>();
    }

    //包含两组坐标
     public class MixedCAD_Point 
    {
        //客图原始坐标
        public CAD_Point CustomerPoint { get; set; } = new CAD_Point();
        //是否转换成功
        public Boolean TransF { get; set; } = false;
        //转换 相对分中坐标(手动模式默认用这个区推算)
        public CAD_Point TransSplitPoint { get; set; } = new CAD_Point();
        //用于做推算逻辑的点坐标
        public CAD_Point UsePoint { get; set; } = new CAD_Point();
    }

    //孔 用于筛选(利用距离) 临时变量
    public class TempFilterByCDInfo
    {
        public MixedCAD_Point pointInfo { get; set; } = new MixedCAD_Point();
        public double CD { get; set; } = 0;
    }

    public class MixedCAD_Circle
    {
        public ObjectId CAD_ObjectId { get; set; }
        public Boolean IsBlockEleFlag { get; set; } = false;
        //块坐标
        public MixedCAD_Point BlockRefPosition { get; set; } = new MixedCAD_Point();
        //圆点坐标
        public MixedCAD_Point CenterPoint { get; set; } = new MixedCAD_Point();
        //直径
        public double Diameter { get; set; }

        public static bool operator == (MixedCAD_Circle circle1, MixedCAD_Circle circle2)
        {
            if (ReferenceEquals(circle1, null) && ReferenceEquals(circle2, null))
                return true;
            if (ReferenceEquals(circle1, null) || ReferenceEquals(circle2, null))
                return false;
            Boolean F1 = Math.Round(circle1.CenterPoint.CustomerPoint.X, 3) == Math.Round(circle2.CenterPoint.CustomerPoint.X, 3);
            Boolean F2 = Math.Round(circle1.CenterPoint.CustomerPoint.Y, 3) == Math.Round(circle2.CenterPoint.CustomerPoint.Y, 3);
            Boolean F3 = circle1.Diameter == circle2.Diameter;
            return F1 && F2 && F3;
        }

        // 重载 != 运算符
        public static bool operator !=(MixedCAD_Circle circle1, MixedCAD_Circle circle2)
        {
            // 使用已经定义的 == 运算符
            return !(circle1 == circle2);
        }

        // Equals 方法用于配合重载的 == 运算符
        public override bool Equals(object obj)
        {
            if (obj is MixedCAD_Circle other)
                return this == other;
            return false;
        }
    }

    //客图 CAD 组装图 全部的图元信息
    public class AssemViewCADInfo
    {
        public List<MixedCAD_Line> ACLList { get; set; } = new List<MixedCAD_Line>();
        public List<MixedCAD_Line> AVLList { get; set; } = new List<MixedCAD_Line>();
        public List<MixedCAD_Arc> AArcList { get; set; } = new List<MixedCAD_Arc>();
        public List<MixedCAD_Circle> ACirList { get; set; } = new List<MixedCAD_Circle>();
        public List<MixedCAD_Text> ATextList { get; set; } = new List<MixedCAD_Text>();
        public List<CAD_Dimension> ADimList { get; set; } = new List<CAD_Dimension>();
        public List<MixedCAD_Curve> ACurvelist { get; set; } = new List<MixedCAD_Curve>();
        //多段线转换出来的直线
        public List<MixedCAD_Line> ATranPolyLList { get; set; } = new List<MixedCAD_Line>();
        ////混合组装的吊令图元信息
        //public List<AralinPrimions> APList { get; set; } = new List<AralinPrimions>();
    }

    //组装图额外辅助识别的信息
    public class AssAddAuxInfo
    {
        public Boolean IShapedF { set; get; }
        public List<MixedHoleInfo> mixedTopHoleInfoList { set; get; } = new List<MixedHoleInfo>();
        public List<double> FTVBoardXList { set; get; } = new List<double>();
        public double? holeRefLength
        {
            get
            {
                if (mixedTopHoleInfoList.Count > 0)
                {
                    List<double> allDimList = new List<double>();
                    for (int i = 0; i < mixedTopHoleInfoList.Count; i++)
                        allDimList.AddRange(mixedTopHoleInfoList[i].DimList);
                    return allDimList.Max(item => item) + 5;
                }
                else
                    return null;
            }
        }
    }

    //板区间LX RX坐标
    public class BoardLXRXInfo
    {
        public double LX { get; set; }
        public double RX { get; set; }

        public BoardLXRXInfo(double lx, double rx)
        {
            LX = lx;
            RX = rx;
        }
    }

    //推算过程中 方铁的信息
    public class ReckFangtieInfo
    {
        //位置 判定哪块方铁
        public FPosType fPosType { get; set; } = FPosType.NONE;
        //方铁外形 
        public FangtieAppType fangtieAppType { get; set; } = FangtieAppType.None;
        //左右两侧X坐标
        public double? LX { get; set; } = null;
        public double? RX { get; set; } = null;
        public double? Width { get; set; } = null;
    }

    //方铁外形
    public enum FangtieAppType
    {
        None,//未定义
        Stand,//直身
        ao,//凹
        tu//凸
    }

    public enum BushBoardType
    {
        NONE,//未判定
        A,//无托A套
        B //带托B套
    }

    //判定情况
    public enum CJudgeType
    {
        NONE,//未判定
        Y,//有
        N//无
    }

    //客图 板上关于套的信息
    public class BoardAboutBushInfo : IEquatable<BoardAboutBushInfo>
    {
        //板UID
        public string BoardUID { get; set; }
        //板上套类型
        public BushBoardType BushType { get; set; } = BushBoardType.NONE;
        public override bool Equals(object obj)
        {
            return Equals(obj as BoardAboutBushInfo);
        }

        public bool Equals(BoardAboutBushInfo other)
        {
            if (other == null)
                return false;
            return this.BoardUID == other.BoardUID && this.BushType == other.BushType;
        }
    }

    //基准角数据
    public class AngleInfo
    {
        //角方向
        public AngleDir DirType { get; set; } = AngleDir.BR;
        //半径
        public double Radius { get; set; }
        //角类型
        public AngleType AType { get; set; } = AngleType.NONE;
    }

    //投影图孔的混合信息
    public class MixedHoleInfo
    {
        public MixedCAD_Point CenterPoint { get; set; } = new MixedCAD_Point();
        //同心圆的各种Dim
        public List<double> DimList = new List<double>();
    }

    //收集轮廓策略返回的数据
    public class ColProInfo
    {
        //是否I型模架
        public Boolean IShapedF { get; set; }
        //由投影图反馈的X坐标集合
        public List<double> FTVBoardXList { get; set; } = new List<double>();
        // 以Y坐标作为KEY 收集 斜线
        public Dictionary<double, List<MixedCAD_Line>> OBLineYDic = new Dictionary<double, List<MixedCAD_Line>>();
        // 以Y坐标作为KEY 收集 横线(和板相关)
        public Dictionary<double, List<MixedCAD_Line>> BoardTSLineYDic = new Dictionary<double, List<MixedCAD_Line>>();
        // 以Y坐标作为KEY 收集 横线(和零件相关)
        public Dictionary<double, List<MixedCAD_Line>> ItemTSLineYDic = new Dictionary<double, List<MixedCAD_Line>>();
        // 以Y坐标作为KEY 收集 竖线
        public Dictionary<double, List<MixedCAD_Line>> AVLineYDic = new Dictionary<double, List<MixedCAD_Line>>();
        //合适的板区域候选线
        public List<FullInfoLine> CandidateTLineList = new List<FullInfoLine>();
    }

    //同心圆规范类
    public class ConSpeCircle
    {
        //客图 同心圆类 圆心坐标
        public CAD_Point CustomerConHPoint { get; set; } = new CAD_Point();
        //圆心的 相对分中坐标
        public CAD_Point ConRefPoint { get; set; } = new CAD_Point();

        //public MixedCAD_Point CenterPointInfo { get; set; } = new MixedCAD_Point();
        //这一类 规格特征(Dim大小从小到大排序 然后组合成字符串)
        public string SpeTrait { get; set; }
        //各圆直径 集合
        public List<double> DimList { get; set; } = new List<double>();
        //于方铁的位置
        public FPosType fPosType { get; set; } = FPosType.NONE;
        //数量特征 && 规格特征 相同 可判定为一类
        public static bool operator ==(ConSpeCircle Item1, ConSpeCircle Item2)
        {
            if (ReferenceEquals(Item1, null) && ReferenceEquals(Item2, null))
                return true;
            if (ReferenceEquals(Item1, null) || ReferenceEquals(Item2, null))
                return false;
            Boolean F2 = Item1.SpeTrait.Equals(Item2.SpeTrait);
            return F2;
        }
        public static bool operator !=(ConSpeCircle Item1, ConSpeCircle Item2)
        {
            return !(Item1 == Item2);
        }
        public override bool Equals(object obj)
        {
            if (obj is ConSpeCircle other)
            {
                return this == other;
            }
            return false;
        }

    }

    //投影图数据信息
    public class TopViewInfoData
    {
        //基准角信息
        public AngleInfo BaseAngleInfo = new AngleInfo();

        //横线字典
        public Dictionary<double, List<FullInfoLine>> TransverseLineDic { get; set; } = new Dictionary<double, List<FullInfoLine>>();

        //竖线字典
        public Dictionary<double, List<FullInfoLine>> VerticalLineDic { get; set; } = new Dictionary<double, List<FullInfoLine>>();

        //同心圆字典
        public Dictionary<string, List<ConSpeCircle>> CircleDic { get; set; } = new Dictionary<string, List<ConSpeCircle>>();

        //中心线集合
        public List<MixedCAD_Line> TopViewCenterLineList { get; set; } = new List<MixedCAD_Line>();

        //中心点
        public MixedCAD_Point ModlCenterInfo { get; set; } = new MixedCAD_Point();

        //圆弧(精框识别需要用上)
        public List<MixedCAD_Arc> ArcList { get; set; } = new List<MixedCAD_Arc>();

        //EGP中托边投影图 同心圆
        public Dictionary<CircleKey, List<MixedCAD_Circle>> EGPConnCircleDic = new Dictionary<CircleKey, List<MixedCAD_Circle>>();

        //投影图最长线
        public double MostLLength { get; set; } = 0.0;

    }

    //精框数据
    public static class FrameInfoData
    {
        //待收集的精框数据
        public static List<FrameLineInfo> FCList { get; set; } = new List<FrameLineInfo>();
        //最终整理出来的数据
        public static FrameItem FRItem { get; set; } = new FrameItem();
    }

    //精框单条线段数据类型
    public class FrameLineInfo
    {
        public FrameLineType FLineType { get; set; } = FrameLineType.NONE;
        //直线(横 竖)
        public FullInfoLine TVLine { get; set; } = new FullInfoLine();
        //圆弧
        public MixedCAD_Arc ArcLine { get; set; } = new MixedCAD_Arc();
        //相连顺序
        public int SortNum { get; set; } = -1;
        //扫描点类型
        public ScanPointType ScanPType { get; set; } = ScanPointType.NONE;
    }

    //需要扫描的点
    public enum ScanPointType
    {
        NONE,//未判定
        S,//起点
        E//终点
    }

    //精框线段类型
    public enum FrameLineType
    {
        NONE,//未判定
        T,//直 横线
        V,//直 竖线
        ARC//圆弧
    }

    //角类型
    public enum AngleType
    {
        NONE = -1,//未判定
        COR,//转角 倒角
        BK,//避空
        XBK,//X避空
        YBK,//Y避空   
    }

    //角方向
    public enum AngleDir
    {
        NONE = -1,//未判定
        TL,//左上
        TR,//右上
        BL,//左下
        BR //左上
    }

    //板区间信息
    [Serializable]
    public class BoardSectionItem : ICloneable
    {
        //板在数据中的唯一标识 BoardCode + 序号
        public string BoardUID { get; set; }
        //板Code
        public string BoardCode { get; set; }
        public string BoardName { get; set; }
        public FullInfoLine OverheadLine { get; set; } = new FullInfoLine();
        //下方线(指该板第二条线信息) 下方线+厚 至 下方线 就是 第一条线信息
        public FullInfoLine BottomLine { get; set; } = new FullInfoLine();
        //板长
        public double PlateLength { get; set; } = 0.0;
        //板厚
        public double PlateThick { get; set; } = 0.0;
        //符合区间范围的参考板厚标注集合
        public List<CAD_Dimension> DimensionThickList = new List<CAD_Dimension>();
        //标注供参考的板厚
        public double DimensionPlateThick { get; set; } = 0.0;
        //板宽
        public double PlateWidth { get; set; } = 0.0;
        //数量
        public int Num { get; set; } = 1;
        //材质 默认50#
        public SteelItem Steel { get; set; } = new SteelItem();
        //孔距是否标准
        public StandardType PitchHoleStandard { get; set; } = StandardType.Untried;
        //中托司孔距是否标准
        public StandardType EGPPitchHoleStandard { get; set; } = StandardType.Untried;
        //吊令信息
        public HangingOrderItem Hanging { get; set; } = new HangingOrderItem();
        //加工框数据
        public FrameItem frameItem { get; set; } = new FrameItem();
        //客图 板相对参考坐标
        public CAD_Point CusBCPoint { get; set; } = new CAD_Point(0, 0, 0);
        //推算 加工 绝对参考坐标(相对于整套模架来计算的)
        public CAD_Point ProBCPoint { get; set; } = new CAD_Point();
        //离空值(该板的上区域界线)
        public double OverAirborneValue { get; set; } = 0.0;
        //板线序号
        public int plateLineNo { get; set; }
        //位于A板以上(及A板)或以下
        public UnloadMoldPosType withaBoardPosType { get; set; } = UnloadMoldPosType.NONE;
        //额外方铁信息(用于判定方铁板的信息)
        public ExtraFInfo extraFInfo { get; set; } = new ExtraFInfo();
        //是否手动插入 用于+-板操作
        public Boolean ManualOperFlag { get; set; } = false;
        //是否已被识别 用于+-板操作前的校验
        public Boolean ReFlag { get; set; } = false;
        //用户备注
        public string UIRemark { get; set; } = "";
        //左右边界X信息
        public BoardLRBoundInfo boardLRBoundInfo = new BoardLRBoundInfo();
        public object Clone()
        {
            return this.MemberwiseClone();
        }

    }

    //板区域左右X边界信息
    public class BoardLRBoundInfo
    {
        public double? BoardLX { get; set; } = null;
        public double? BoardRX { get; set; } = null;
    }

    //Line Type & Num Match Info
    public class BoardLineShapeAndNumType
    {
        public MoldLineShareType shapeType { get; set; } = MoldLineShareType.NONE;
        public int lineNum { get; set; }
        public List<double> lineLengthList { get; set; } = new List<double>();
        public CandidateLineNumType lineNumType { get; set; } = CandidateLineNumType.NONE;
    }

    public enum MoldLineShareType
    {
        NONE,//未判定
        I,//工字板 底板等长线
        S,//A B 推 托等(凸也算) H型的 还包括了工字板 底板等 I
        EPFP,//针板线
    }

    //板线和板数量对应关系
    public enum CandidateLineNumType
    {
        NONE,
        CONFORM,
        LESS,
        MOME,
        ZERO
    }

    //图纸 图层 颜色信息
    public class CAD_LayerColorInfo
    {
        public string layerName { set; get; }
        public string layerColorIndex { set; get; }
    }

    //钢材信息
    [Serializable]
    public class SteelItem
    {
        //钢材名称
        public string SteelName { get; set; } = "50#";
        public string SteelCode { get; set; } = "C01";
        //在图中钢材文字的大小
        public double SteelStrSize { get; set; } = 0;
        //是否已匹配
        public Boolean MatchFlag { get; set; } = false;
    }

    public enum UnloadMoldPosType
    {
        NONE,//未定义
        aBoardUp,//A板以上
        aBoardDown//A板一下
    }

    //板件坐标信息(相对于投影图中心) 
    public class BoardCoordinateInfo
    {
        //板在数据中的唯一标识 BoardCode + 序号
        public string BoardUID { get; set; }
        public string BoardName { get; set; }
        public double plate_X0 { get; set; } = 0.0;
        public double plate_Y0 { get; set; } = 0.0;
        public double plate_Z0 { get; set; }
        //板序号
        public int plate_LineNo { get; set; }
        //冗余字段 专门用于处理方铁类型
        public FPosType fPosType { get; set; } = FPosType.NONE;
        //X中心坐标 专门用于处理方铁
        public double CenterX { get; set; }
    }

    //关联孔相对于投影图 的分中数据
    [Serializable]
    public class RefHoleCenterSplitInfo
    {
        //零件名称
        public DItemNameType ItemNameType { get; set; } = DItemNameType.NONE;
        public int DBDim { get; set; } = 0;
        //在数据库中对应的类型(用于转换查数)
        public string DBItemName { get; set; }
        //相对于板中心的分中坐标信息
        public List<StandardHoleData> SplitInfoList { get; set; } = new List<StandardHoleData>();
    }

    public enum StandardType
    {
        Standard,//标准
        NonStandard,//非标
        Untried //未审
    }

    // 吊令参数数据
    [Serializable]
    public class HangingOrderItem
    {
        //客图是否有吊令 默认没有
        public Boolean BluePrintHHFlag { get; set; } = false;

        //吊令参数
        public HangingOrderItemParam HangingParam { get; set; } = new HangingOrderItemParam();

        //直径是否标准
        public StandardType DimStandardType { get; set; } = StandardType.Untried;

        //位置是否标准
        public StandardType PosstandardType { get; set; } = StandardType.Untried;

        //默认 标准 直径和位置(左右偏移或上下偏移 <= 2MM )符合标准，才为“标准”，否则为“非标”，没有识别到为“未审
        public StandardType standardType { get; set; } = StandardType.Untried;

        //拉令数量 默认 2
        public int Num { get; set; } = 0;
    }

    //标准吊令上下一级直径参数
    public class PullingDimItem
    {
        public List<int> ABDimList { get; set; } = new List<int>();
        public List<int> skmbDimList { get; set; } = new List<int>();
        public List<int> tuobanDimList { get; set; } = new List<int>();
        public List<int> dbmbDimList { get; set; } = new List<int>();
        public List<int> tuibanDimList { get; set; } = new List<int>();
        public List<int> fangtieDimList { get; set; } = new List<int>();
        public List<int> zhenbanDimList { get; set; } = new List<int>();
    }

    //吊令参数 
    [Serializable]
    public class HangingOrderItemParam
    {
        //吊令中心坐标
        public CAD_Point CenterPoint { get; set; } = new CAD_Point();
        //吊令直径
        public double Dim { get; set; } = 0.0;
        //吊令与板 分中X
        public double DicX { get; set; } = 0.0;
        //吊令与板 分中Y
        public double DicY { get; set; } = 0.0;
    }

    //零件组成部分 名称
    public enum ItemPartCodeType
    {
        NONE,//未定义
        Dim,//直径
        TD,//导柱/拉杆托位
        BushSize,//导套外径
        BushTD,//导套托位
        BK//避空孔 用于计算拉杆和导柱穿过板留下的孔
    }

    //最终的零件信息(识别出来的零件)
    public class SingleItem
    {

        //零件UID 
        public string ItemUID { get; set; }
        public string ItemCode { get; set; }
        public DItemNameType ItemNameType { get; set; }
        //零件名称
        public string ItemName { get; set; }
        //最高点 
        public double? PeakY { get; set; } = null;
        //最低点
        public double? NadirY { get; set; } = null;
        //组装图中心X坐标
        public double AssembleCenterPointX { get; set; } = 0;
        //组装图 客图 中心X坐标
        public double AVCustomerCX { get; set; } = 0;
        //组装图 推算出来 中心X坐标
        public double AVSplitCX { get; set; } = 0;
        //投影图中心X坐标
        public double TVCPX { get; set; } = 0;
        //零件上螺丝的理论长度 根据公式计算出来的 落数也是这个长度
        public double TheoryScrewH { get; set; } = 0.0;
        //零件上螺丝实际长度客户来图
        public double RealScrewH { get; set; } = 0.0;
        //零件理论长度
        public double TheoryH { get; set; } = 0.0;
        //零件实际长度
        public int RealH { get; set; } = 0;
        //实际推算加工用的螺丝实际长度
        public double ProcessScrewH { get; set; } = 0; 
        //零件牙数据
        public ToochItem ToochInfo { get; set; } = new ToochItem();
        //零件 匹配的孔
        public ScrewHole MatchScrewHole { get; set; } = new ScrewHole();
        //补齐零件关联的相同规格的孔
        public List<ScrewHole> RelScrewHoleList { get; set; } = new List<ScrewHole>();
        //零件关联的相同规格的孔 就是零件的数量
        public int? ItemNum { get; set; }
        public RefHoleCenterSplitInfo HSplitInfo { get; set; } = new RefHoleCenterSplitInfo();
        //标准型号下 
        //零件孔理论需要匹配标准的孔数量
        public int NeedMathHoleNum { get; set; } = 0;
        //零件孔实际匹配标准的孔数量
        public int ActMatchHoleNum { get; set; } = 0;
        //普通零件孔距类型判定
        public ItemHolesPitchType HolePitchType { get; set; } = ItemHolesPitchType.NONE;
        //EGP孔实际匹配标准的孔数量
        public int EGPActMatchHoleNum { get; set; } = 0;
        //EGP孔理论需要匹配标准的孔数量
        public int? EGPNeedMathHoleNum { get; set; } = null;
        //EGP孔距类型判定
        public ItemHolesPitchType EGPHolePitchType { get; set; } = ItemHolesPitchType.NONE;
        //关联的孔距X方向
        public int RealHoleX { get; set; } = 0;
        //关联的孔距Y方向
        public int RealHoleY { get; set; } = 0;
        //直径
        public double Dim { get; set; } = 0.0;
        //导柱/拉杆托位
        public decimal TD { get; set; } = 0;
        //托位深度
        public decimal TH { get; set; } = 0;
        
        //导套外径
        public int BushSize { get; set; } = 0;
        //导套托位
        public int BushTD { get; set; } = 0;
        //实际加工入数 
        public decimal InputTD { get; set; } = 0;
        public decimal InputTH { get; set; } = 0;
        public int InputBushSize { get; set; } = 0;
        public int InputBushTH { get; set; } = 0;
        public int InputBushTD { get; set; } = 0;
        //导套托位深度
        public decimal BushTH { get; set; } = 0;
        //拉杆避空孔
        public int BK { get; set; } = 0;
        //零件 托位 所在板的位置
        public InBoardPosType TDPosType { get; set; } = InBoardPosType.NONE;
        //托位所在的板
        public BoardSectionItem TDBoard { get; set; } = new BoardSectionItem();
        //套 托位 所在板的位置
        public InBoardPosType BushTDPosType { get; set; } = InBoardPosType.NONE;
        //套 托位 所在板
        public BoardSectionItem BushTDBoard { get; set; } = new BoardSectionItem();
        //盲孔板数据(螺丝牙锁的板)
        public BoardSectionItem BlindHoleBoard { get; set; } = new BoardSectionItem();
        //仅提供给套(套 所在板)
        public List<BoardSectionItem> BushBoardList { get; set; } = new List<BoardSectionItem>();
        //(螺丝)通孔板数据集合
        public List<BoardSectionItem> ScrewDimThroughHBList { get; set; } = new List<BoardSectionItem>();
        //(非螺丝除套外 零件)通孔板数据集合
        public List<BoardSectionItem> ItemDimThroughHBList { get; set; } = new List<BoardSectionItem>();

        public ItemBlindInfo blindInfo { get; set; } = new ItemBlindInfo();
        //归于此零件的全部避空信息
        public List<ItemBKInfo> ItemBKInfoList { get; set; } = new List<ItemBKInfo>();
        //是否拉杆变导柱
        public Boolean PRTransitionGPFlag { get; set; } = false;
        //零件加工备注
        public string Remark { get; set; } = "";
        //显示的顺序
        public int SortNo { get; set; }
        //装配孔的加工行号
        public int lineNo { get; set; } = -1;
    }
    
    //零件 盲孔 信息
    public class ItemBlindInfo
    {
        public double H { get; set; }
        public string BlindBoardUID { get; set; }
        public InBoardType BlindInBoardType { get; set; } = InBoardType.None;
    }

    //零件 每段 避空信息
    public class ItemBKInfo
    {
        //避空总深度
        public double BKHH { get; set; } = 0;
        //避空穿过的所有板件UID
        public List<string> BoardUIDList { get; set; } = new List<string>();
        //避空详细信息
        public List<DeadReckBKTempInfo> DetailInfoList { get; set; } = new List<DeadReckBKTempInfo>();
    }

    //推算过程中的 避空在每块板的(临时变量)
    public class DeadReckBKTempInfo
    {
        public string BKInBoardUID { get; set; }
        //深度
        public double H { get; set; }
        public InBoardType BKInBoardType { get; set; } = InBoardType.None;
    }

    //孔在板中的情况
    public enum InBoardType
    {
        None,//未判定
        Up,//上方(下方没通)
        Through,//整个通
        Down//下方(上方没通)
    }

    //
    // public class 

    //手工零件 手工界面的数据
    [Serializable]
    public class LabourSingleItem
    {
        public string ItemUID { get; set; }
        public DItemNameType ItemNameType { get; set; } = DItemNameType.NONE;
        public string ItemCode { get; set; }
        public string ItemName { get; set; }
        public int ItemNum { get; set; }
        public double ItemL { get; set; }
        //数据库里面的备注 主要用于区分套是哪块板上的 用于计算套长度
        public string ItemRemark { get; set; }
        //界面上的备注 主要用于记录用户的零件备注
        public string UIRemark { get; set; }
        public double ItemDim { get; set; }
        //客图长度 用于上传记录JSON序列化放数据 螺丝一般不给
        public double? CGItemL { get; set; } = null;
        public LabourSingleItem()
        {

        }
    }

    //EGP加工项目
    public class EGPProcessinfo
    {
        public string processName { get; set; }
        //长度
        public int length { get; set; }
        //直径 
        public double dim { get; set; }
        public int num { get; set; }
        //孔距长
        public double? holeL { get; set; }
        //孔距宽
        public double? holeW { get; set; }
        //不供零件
        public Boolean noFurnishF { get; set; } = false;
    }

    //弹簧孔加工项目
    public class SHoleProcessInfo
    {
        public double depth { set; get; }
        public double dim { set; get; }
        public int num { set; get; }
        public Boolean hasRPPos { set; get; }
        public double? posL { set; get; }
        public double? posW { set; get; }
    }

    //零件的孔距标准情况
    public class IHPSInfo
    {
        public string ItemUID { get; set; }
        public string ItemCode { get; set; }
        public DItemNameType ItemNameType { get; set; }
        //客图&孔关系
        public RHoleSceneType RType { get; set; } = RHoleSceneType.None;
        //孔推算情况
        public ItemHolesPitchType SType { get; set; } = ItemHolesPitchType.NONE;
        //经过的板
        //public List<BoardHoleStandardInfo> GoByBoardList = new List<BoardHoleStandardInfo>();
        public List<string> GoByBoardList = new List<string>();
    }

    //零件孔距标准类型 TODO
    public enum ItemHolesPitchType
    {
        NONE,//未判定
        //NOSS,//模架型号不标准
        //SS_NoNeed,//模架型号标准 但不需要判断该零件标准
        NS,//模架型号标准 但零件不标准
        SS,//模架型号标准 零件标准
    }

    //回针截断点类型
    public enum RPPointTraitType
    {
        NONE,//未定义
        LHight,//左高
        RHight//右高
    }

    //回针截断点信息
    public class RPCutOffInfo
    {
        public CAD_Point LPoint { get; set; } = new CAD_Point();
        public CAD_Point RPoint { get; set; } = new CAD_Point();
        public RPPointTraitType traitType { get; set; } = RPPointTraitType.NONE;
    }

    //套托位的部分参数(属于中间过渡推断数据)
    public class PartBushTDArgItem
    {
        //托位X值(横)
        public double XLength { get; set; } = 0;
        //托位孔数据
        public double BushHoleH { get; set; } = 0;
        //托位高度
        public double BushTH { get; set; } = 0;
        //导套托位所在的板
        public BoardSectionItem BushTDBoard { get; set; } = new BoardSectionItem();
        //导套托位在板的位置
        public InBoardPosType BushTDPosType { get; set; } = InBoardPosType.NONE;
    }

    //单个导套托位部位信息(托位高度||托位孔)
    public class SingleBushTDPartItem
    {
        //X值
        public double XLength { get; set; } = 0;
        //托位高度
        public double H { get; set; } = 0;
        //导套托位所在的板
        public BoardSectionItem BushTDBoard { get; set; } = new BoardSectionItem();
        //导套托位在板的位置
        public InBoardPosType BushTDPosType { get; set; } = InBoardPosType.NONE;
    }

    public class SingleBushTDPartItemComparer : IEqualityComparer<SingleBushTDPartItem>
    {
        public bool Equals(SingleBushTDPartItem Item1, SingleBushTDPartItem Item2)
        {
            Boolean F1 = Item1.BushTDBoard.BoardUID == Item2.BushTDBoard.BoardUID;
            Boolean F2 = Item1.H == Item2.H;
            Boolean F3 = Item1.BushTDPosType == Item2.BushTDPosType;
            return F1 && F2 && F3;
        }
        public int GetHashCode(SingleBushTDPartItem obj)
        {
            unchecked
            {
                int hash = 17;
                hash = hash * 23 + obj.H.GetHashCode();
                hash = hash * 23 + obj.BushTDBoard.BoardUID.GetHashCode();
                return hash;
            }
        }
    }

    //导套连套索引信息
    public class ContinueBushIInfo
    {
        public string BeginBoardUID { get; set; }
        public string EndBoardUID { get; set; }
    }

    public class ExtraFInfo
    {
        //默认
        public Boolean FFlag { get; set; } = false;
        //默认未判定
        public FPosType fPosType { get; set; } = FPosType.NONE;
        //相对
        public CAD_Point RelFBCPoint { get; set; } = new CAD_Point();
    }

    //在板的上边线还是下边线
    public enum InBoardPosType
    {
        NONE,//未判定
        BoardUp,//板上延线
        BoardDown,//板下延线
        NEXIT //不存在
    }

    //零件尖信息
    public class ToochItem
    {
        //是否存在尖
        public Boolean ExistTheTip { get; set; } = false;
        //中心X坐标
        public double CenterPointY { get; set; } = 0;
        //盲牙深
        public double BlindToochH { get; set; } = 0;
        //实际加工使用的牙深
        public double ProcessBlindToochH { get; set; } = 0;
        public ToochParam toochParam { get; set; } = new ToochParam();
    }

    //牙参数 Dim TD
    public class ToochParam
    {
        public ToochDim ToochDimPart { get; set; } = new ToochDim();
        public ToochTD ToochTDPart { get; set; } = new ToochTD();
    }

    public class ToochDim
    {
        public Boolean HasF { get; set; } = false;
        public double Dim { get; set; } = 0;
        public MixedCAD_Line LLine { get; set; } = new MixedCAD_Line();
        public MixedCAD_Line RLine { get; set; } = new MixedCAD_Line();
    }

    public class ToochTD
    {
        public Boolean HasF { get; set; } = false;
        public double TD { get; set; } = 0;
        public MixedCAD_Line LLine { get; set; } = new MixedCAD_Line();
        public MixedCAD_Line RLine { get; set; } = new MixedCAD_Line();
    }

    //在组装图上的托位 位置  
    public enum TDAreaType
    {
        NONE,//未判定
        TDInFirst,//托位在第一块板上
        TDInLast//托位在最后一块板上
    }

    //收集的单个零件信息
    public class CSingleItem
    {
        public double AVSplitCX { get; set; } = 0;
        public MixedCAD_Point CenterPoint { get; set; } = new MixedCAD_Point();
        //收集该零件的各个部位 竖线集合
        public List<CSinglePartItem> InfoList { get; set; } = new List<CSinglePartItem>();
        //零件的尖
        public ToochItem ToochInfo { get; set; } = new ToochItem();
        //匹配上的关联的孔
        public ScrewHole MatchScrewHole { get; set; } = new ScrewHole();
        //零件关联的相同规格的孔
        public List<ScrewHole> RelScrewHoleList { get; set; } = new List<ScrewHole>();
    }

    //收集的零件的某组信息
    public class CSinglePartItem
    {
        public ItemPartCodeType ItemType { get; set; } = ItemPartCodeType.NONE;
        //组装图 推算出来的分中 中心X
        public double AVSplitCX { get; set; }
        //组装图 客图 中心X
        public double AVCustomerCX { get; set; }
        //投影图 中心X
        public double TVCPX { get; set; }
        //左右两条线
        public MixedCAD_Line LLine { get; set; } = new MixedCAD_Line();
        public MixedCAD_Line RLine { get; set; } = new MixedCAD_Line();
        //横向长度
        public double XLength { get; set; }
        //纵向长度
        public double YLength { get; set; }
        //该零件部位 匹配的孔
        public ScrewHole MatchScrewHole { get; set; } = new ScrewHole();
    }

    public class CSinglePartItemComparer : IEqualityComparer<CSinglePartItem>
    {
        public bool Equals(CSinglePartItem Item1, CSinglePartItem Item2)
        {
            Boolean TypeFlag = Item1.ItemType == Item2.ItemType;
            Boolean CPFlag = Item1.TVCPX == Item2.TVCPX;
            Boolean LLXFlag = Item1.LLine.StartPoint == Item2.LLine.StartPoint;
            Boolean RLXFlag = Item1.RLine.StartPoint == Item2.RLine.StartPoint;
            return TypeFlag & CPFlag & LLXFlag & RLXFlag;
        }

        public int GetHashCode(CSinglePartItem obj)
        {
            unchecked
            {
                int hash = 17;
                hash = hash * 23 + obj.ItemType.GetHashCode();
                hash = hash * 23 + obj.TVCPX.GetHashCode();
                return hash;
            }
        }
    }

    //
    public class DeadReckBKTempInfoComparer : IEqualityComparer<DeadReckBKTempInfo>
    {
        public bool Equals(DeadReckBKTempInfo info1, DeadReckBKTempInfo info2)
        {
            Boolean F1 = true;
            info1.BKInBoardUID.Equals(info2.BKInBoardUID);
            Boolean F2 = info1.H == info2.H;
            Boolean F3 = info1.BKInBoardType == info2.BKInBoardType;
            return F1 && F2 && F3;
        }

        public int GetHashCode(DeadReckBKTempInfo obj)
        {
            unchecked
            {
                int hash = 17;
                hash = hash * 23 + obj.BKInBoardType.GetHashCode();
                hash = hash * 23 + obj.BKInBoardUID.GetHashCode();
                hash = hash * 23 + obj.H.GetHashCode();
                return hash;
            }
        }
    }


    public class ItemBKInfoComparer : IEqualityComparer<ItemBKInfo>
    {
        public bool Equals(ItemBKInfo info1, ItemBKInfo info2)
        {
            Boolean F1 = info1.BKHH == info2.BKHH;
            Boolean F2 = info1.BoardUIDList.Equals(info2.BoardUIDList);
            return F1 && F2;
        }

        public int GetHashCode(ItemBKInfo obj)
        {
            unchecked
            {
                int hash = 17;
                hash = hash * 23 + obj.BKHH.GetHashCode();
                hash = hash * 23 + obj.BoardUIDList.GetHashCode();
                return hash;
            }
        }
    }

    public class MixHoleGorupInfo
    {
        //客图孔坐标
        public List<MixedCAD_Point> CustomerHolePList = new List<MixedCAD_Point>();
        //是否有数据
        public Boolean HasF { get; set; } = false;
    }

    //一组孔的标签
    public class HoleGroupTag
    {
        public DItemNameType holeType { get; set; } = DItemNameType.NONE;
        //收集 客图 孔参数 集合
        public List<MixedCAD_Point> CollectionHPList { get; set; } = new List<MixedCAD_Point>();
        //孔关键参数
        public ScrewHole holeArg { get; set; } = new ScrewHole();
        //这组孔的分中距离长度
        public double CD { get; set; }

        //客图 绘制 孔直径数据
        public List<double> drawDimList = new List<double>();

        //关键 直径数据
        public List<double> dimList = new List<double>();
    }

    //一组孔的标签 比较器
    public class HoleGroupTagComparer : IEqualityComparer<HoleGroupTag>
    {
        public bool Equals(HoleGroupTag x, HoleGroupTag y)
        {
            if (x == null && y == null)
                return true;
            if (x == null || y == null)
                return false;
            Boolean F1 = x.CD == y.CD;
            string xdim = x.dimList.OrderBy(item => item).ToList().ToString();
            string ydim = y.dimList.OrderBy(item => item).ToList().ToString();
            Boolean F2 = xdim.Equals(ydim);
            return F1 && F2;
        }
        public int GetHashCode(HoleGroupTag obj)
        {
            if (obj == null)
                return 0;
            return obj.CD.GetHashCode();
        }
    }

    //接近同心圆 辅助信息
    public class ApprConCircleKey
    {
        public CircleKey refKey = new CircleKey();
        public Boolean comF { get; set; } = false;
    }

    //螺丝孔 数据 全量
    [Serializable]
    public class ScrewHole
    {
        //判断为拉杆的优先级
        public int SPPriority { get; set; } = -1;
        //中心坐标
        public MixedCAD_Point CenterPoint { get; set; } = new MixedCAD_Point();
        //推算过程中采用的 中心坐标
        public CAD_Point UseCenterPoint { get; set; } = new CAD_Point();
        //直径
        public double Dim { get; set; } = 0.0;
        //导柱/拉杆托位
        public int TD { get; set; } = 0;
        //导套外径
        public int BushSize { get; set; } = 0;
        //导套托位
        public int BushTD { get; set; } = 0;
        //拉杆避空孔
        public int BK { get; set; } = 0;
        //冗余字段 用于判断在左右哪侧方铁
        public FPosType fPosType { get; set; } = FPosType.NONE;
        //孔距是否标准
        public StandardType standardType { get; set; } = StandardType.Untried;
        //关联的圆||圆弧的ObjectId
        //public List<ObjectId> ObjectIdList { get; set; } = new List<ObjectId>();

        //比较孔数据
        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
                return false;
            ScrewHole AnOther = (ScrewHole)obj;
            Boolean F0 = CenterPoint.CustomerPoint.X == AnOther.CenterPoint.CustomerPoint.X && CenterPoint.CustomerPoint.Y == AnOther.CenterPoint.CustomerPoint.Y;
            Boolean F1 = Dim == AnOther.Dim;
            Boolean F2 = TD == AnOther.TD;
            Boolean F3 = BushTD == AnOther.BushTD;
            Boolean F4 = BushSize == AnOther.BushSize;
            return F0 && F1 && F2 && F3 && F4;
        }

    }

    //板候选线关联信息 
    public class CandidateBLIAboutInfo
    {
        //长度
        public double? Length { get; set; } = null;
        //长度数量
        public int? LNum { get; set; } = null;
        //列表
        public List<FullInfoLine> AboutLList = new List<FullInfoLine>();
        //第一次出现的下标
        public int? FirstIndex { get; set; } = null;
        //最后出现的下标
        public int? LastIndex { get; set; } = null;
        //关联的投影图投影长度(比较接近)
        public double? TVRelL { get; set; } = null;
        public BoardShapeType SType { get; set; } = BoardShapeType.NONE;
    }

    //连接线的颜色辅助信息 用于辅助连接板线策略B
    public class LineAuxStaColorInfo
    {
        //数量
        public int num { get; set; } = 0;
        //颜色
        public string colorName { get; set; }
    }

    //板外形类型
    public enum BoardShapeType
    {
        NONE,//未判定
        I,//工字板
        S,//直身板
        IPRO,//凸板(I模:非标比工字板凸)
        EPFP,//针板
        FRAMEBOX//干扰框线
    }

    //板候选线 
    //单块方铁的全量数据
    public class SingleFangtieItem
    {
        //中心坐标
        public CAD_Point CenterPoint { get; set; } = new CAD_Point();
        //上下区域
        public FullInfoLine OverheadLine { get; set; } = new FullInfoLine();
        public FullInfoLine BottomLine { get; set; } = new FullInfoLine();
        public double PlateWidth { get; set; } = 0.0;
        public double PlateThick { get; set; } = 0.0;
        public FPosType fPosType { get; set; } = FPosType.NONE;
    }

    //用于记录孔与标准的匹配情况
    public class SHoleMatchCondition
    {
        //加工类型
        public DItemNameType ItemNameType;
        //匹配数据库 MC2_3DStandardHoleData Item 字段
        public string Item;
        //一组 相关孔距是否都 标准
        public Boolean MatchFlag;
    }

    //方铁位置类型
    public enum FPosType
    {
        NONE,//未定义
        L,//左
        R,//右
        C,//中间(三方铁场景)
        NF //无方铁场景
    }

    //客图(组装图)拉令 图元组成 两圈圆 单圈圆 一圆&一圆弧
    public class AralinPrimions
    {
        //中心坐标
        public double? CenterX { get; set; } = null;
        public double? CenterY { get; set; } = null;
        //是否是块
        public Boolean IsBlockEleFlag { get; set; } = false;
        //圆集合
        public List<MixedCAD_Circle> CircleList { get; set; } = new List<MixedCAD_Circle>();
        //是否包含圆弧
        public Boolean IsContainArcFlag { get; set; } = false;
        //是否包含半径标注文字
        public Boolean IsContainTextFlag { get; set; } = false;
        //外圈圆弧
        public MixedCAD_Arc OutSideArc { get; set; } = new MixedCAD_Arc();
        //半径文字标注
        public CAD_Text RadiusLabel { get; set; } = null;
    }

    //界面渲染类型
    public enum RenderType
    {
        AfterRecognize,//识别后调用
        AfterRecoginzeFrame,//识别框后调用
        UserOper//用户操作界面后调用
    }

    //可能是码模坑的信息
    public class PatternPitInfo
    {
        //边界X (L/R)
        public double boundaryX { get; set; }
        //长度
        public double length { get; set; }
        //默认未判定
        public FPosType BType { get; set; } = FPosType.NONE;
    }

    //图框坐标信息
    public class PictureFrameCondiInfo
    {
        public double? LX { get; set; } = null;
        public double? RX { get; set; } = null;
        public double? TY { get; set; } = null;
        public double? BY { get; set; } = null;
    }

    public class HoleAbsDistance
    {
        public double absX { get; set; }
        public double absY { get; set; }
    }

    //计算精框相崩的中间量 
    public class FramePhaseCol
    {
        public List<ComputedAngleRes> angList = new List<ComputedAngleRes>();
        public double? FrameMaxY { get; set; }
        public double? FrameMinY { get; set; }
        public double? FrameMaxX { get; set; }
        public double? FrameMinX { get; set; }
    }

    //KO孔加工项目
    public class KOHoleProcessInfo
    {
        public double dim { set; get; }
        public int num { set; get; }
        public double posL { set; get; }
        public double posW { set; get; }
    }

    //上送ERP的各类孔加工数据清单
    public class ProcessDetailListInfo
    {
        //KO孔加工项目
        public KOHoleProcessInfo koHoleProcessinfo { get; set; } = new KOHoleProcessInfo();
        //弹簧孔加工项目
        public SHoleProcessInfo sHoleProcessInfo { get; set; } = new SHoleProcessInfo();
        //中托司加工项目
        public EGPProcessinfo egpProcessinfo { get; set; } = new EGPProcessinfo();
    }

    //手动模式 额外加工参数
    public class MTypeBoardPArg
    {
        public decimal plateX0 { get; set; } = 0;
        public decimal plateY0 { get; set; } = 0;
        public decimal plateZ0 { get; set; } = 0;


    }

    //手动界面 板数据项
    public class ManualBoardItem
    {
        //板在数据中的唯一标识 BoardCode + 序号
        public string BoardUID { get; set; }
        //板Code
        public string BoardCode { get; set; }
        public string BoardName { get; set; }
        //板长
        public double PlateLength { get; set; } = 0.0;
        //板厚
        public double PlateThick { get; set; } = 0.0;
        //板加工坐标参数
        public MTypeBoardPArg PArg { get; set; } = new MTypeBoardPArg();
        //标注供参考的板厚
        public double DimensionPlateThick { get; set; } = 0.0;
        //板宽
        public double PlateWidth { get; set; } = 0.0;
        //数量
        public int Num { get; set; } = 1;
        //材质 默认50#
        public SteelItem Steel { get; set; } = new SteelItem();
        //孔距是否标准
        public StandardType PitchHoleStandard { get; set; } = StandardType.Untried;
        //中托司孔距是否标准
        public StandardType EGPPitchHoleStandard { get; set; } = StandardType.Untried;
        //吊令信息
        public HangingOrderItem Hanging { get; set; } = new HangingOrderItem();
        //加工框数据
        public FrameItem frameItem { get; set; } = new FrameItem();
        //板线序号
        public int plateLineNo { get; set; }
        //是否手动插入 用于+-板操作
        public Boolean ManualOperFlag { get; set; } = false;
        //是否已被识别 用于+-板操作前的校验
        public Boolean ReFlag { get; set; } = false;
        //用户备注
        public string UIRemark { get; set; } = "";
        //板 顺序 用于后续生成加工顺序 关联BoardUID
        public int MBSortNum { get; set; }
    }

    //手动模式 界面的全量 复选框值
    public class MTypeAllCheckBoxVInfo
    {
        public Boolean MGPInverF { get; set; } = false;
        public Boolean MGPOverspBoardF { get; set; } = false;
        public Boolean MRPOverstBoardF { get; set; } = false;
        public Boolean MfangtieLockspBoardF { get; set; } = false;
        public Boolean MRPAddTeethF { get; set; } = false;
        public Boolean MRPScrewF { get; set; } = false;
        public Boolean MEGPF { get; set; } = false;
    }

    //手动模式 零件孔 依赖的其余全量参数
    public class MTypePHoleArg
    {
        public decimal BushDim { get; set; }
        public decimal BushTD { get; set; }
        public decimal BushTH { get; set; }
        public decimal TD { get; set; }
        public decimal TH { get; set; }
        public decimal BK { get; set; }
        public MTypeItemPBInfo PBArgInfo { get; set; } = new MTypeItemPBInfo();
    }

    //手动模式 零件 加工孔 额外 板参数
    public class MTypeItemPBInfo
    {
        //托位板(TD 套 BushTD)
        public string TDBoardUID { get; set; }
        //通板(Dim 套 BushSize)
        public List<string> ThroughBoardUIDList { get; set; } = new List<string>();
        //牙板
        public string ToochBoardUID { get; set; }
        //不通的板
        public string NoThroughBoardUID { get; set; }
        //不通的深度||牙
        public double NTTH { get; set; } = 0;
    }

    //手动界面 零件数据项
    public class ManualItem
    {
        public string ItemUID { get; set; }
        public string ItemCode { get; set; }
        public string ItemName { get; set; }
        public double L { get; set; }
        //套 显示的Dim = 零件的Dim 比如 拉杆套Dim = 拉杆Dim
        public double Dim { get; set; }
        //额外的加工参数
        public MTypePHoleArg holeArg { get; set; } = new MTypePHoleArg();
        //零件孔距W
        public double ItemHW { get; set; }
        //零件孔距L
        public double ItemHL { get; set; }
        //测量长 & 直径
        public double ML { get; set; }
        public double MDim { get; set; }
        public int Num { get; set; }
        public string Remark { get; set; }
        public string UIRemark { get; set; }
        //零件孔距是否标准 默认未审
        public StandardType HoleIsStandard { get; set; } = StandardType.Untried;
        public DItemNameType ItemNameType { get; set; } = DItemNameType.NONE;
        //包含了哪些板UID
        public List<string> BoardUIDList { get; set; } = new List<string>();
        //根据孔距生成分中坐标
        public List<HPoint2D> TempHPointList = new List<HPoint2D>();
    }

    //手动界面 关联的一组孔 数据项 
    public class ManualItemHoleGroup
    {
        //所属零件
        public string ItemUID { get; set; }
        public string ItemCode { get; set; }
        public int Dim { get; set; }
        public ManualItemHoleExtraData ExtraInfo { get; set; } = new ManualItemHoleExtraData();
        public List<ManualHoleItem> HoleList { get; set; } = new List<ManualHoleItem>();
    }

    //手动界面 额外的孔参数
    public class ManualItemHoleExtraData
    {
        public double HoleL { get; set; }
        public double HoleW { get; set; }
    }

    //手动界面 单独一个孔坐标 数据项
    public class ManualHoleItem
    {
        public double X { set; get; }
        public double Y { set; get; }
    }

    public class HoleItemComparer : IEqualityComparer<StandardHoleData>
    {
        public bool Equals(StandardHoleData x, StandardHoleData y)
        {
            Boolean F1 = x.ItemDim == y.ItemDim;
            Boolean F2 = x.ItemNum == y.ItemNum;
            Boolean F3 = x.Item == y.Item;
            return F1 && F2 && F3;
        }
        public int GetHashCode(StandardHoleData obj)
        {
            return obj.ToString().GetHashCode();
        }
    }

    //自动&手动 模式 检测报错提示
    public class AMTypeCheckWarn
    {
        //提示语
        public string tig { get; set; }
        //是否全部通过
        public Boolean warnF { get; set; } = true;
    }

    //手动模式 需要暂存的全量信息
    public class MTypeAllPriInfo
    {
        public List<ManualBoardItem> MBoardList = new List<ManualBoardItem>();
        public List<ManualItem> MItemList = new List<ManualItem>();
        public MTypeAllCheckBoxVInfo CBInfo = new MTypeAllCheckBoxVInfo();
    }
   
    public enum RHoleSceneType
    {
        None,//未判定
        R,//已识别(投影图有 组装图也有)
        T,//投影图有
        NT//投影图没有
    }

    //零件名称 细分
    public enum DItemNameType
    {
        NONE,//未定义
        GuidePin,//导柱
        GuideABush,//A套(导柱)
        GuideBBush,//B套(导柱)
        SupportPin,//拉杆
        SupportPinABush,//A套(拉杆)
        SupportPinBBush,//B套(拉杆)
        NoNozzleMesonSupportPin,//导柱(无介子)
        NoNozzleMesonSupportPinABush,//A套(导柱无介子)
        NoNozzleMesonSupportPinBBush,//B套(导柱无介子)
        EGPPin,//EGP/中托边
        EGPBush,//中托司
        ReturnPin,//回针
        ReturnPinScrew,//回针螺丝
        PinBoardScrew,//针板螺丝
        TopPanelScrew,//面板螺丝
        BottomPanelScrew,//底板螺丝
        SpaceBlockScrew,//方铁螺丝
        GenericScrew,//公制螺丝
        SpringHole,//弹簧孔
        KOHole,//KO孔
        SupportBlock,//支撑柱
        GenericFineHole,//通用精孔
        GenericRoughHole,//通用粗孔
        MalePin,//销钉
        SmallSP,//小拉杆
        Meson,//介子
        MesonScrew,//水介螺丝(介子螺丝)
        ReturnPinScrewMeson//回针介子
    }
    
    //零件 加工类型 -> (数据库) M_Type
    public enum ItemProcessType
    {
        None,//0-特殊时候使用
        GuidePin,//1-导柱
        SupportPin,//2-拉杆
        ReturnPin,//3-回针
        PinBoardScrew,//4-针板螺丝
        TopPanelScrew,//5-面板螺丝
        BottomPanelScrew,//6-底板螺丝
        SpaceBlockScrew,//7-方铁螺丝
        EGP,//8-中托边
        GenericScrew,//9-公制螺丝
        SpringHole,//10-弹簧孔
        KOHole,//11-KO孔
        SupportBlock,//12-支撑柱
        GenericFineHole,//13-通用精孔
        GenericRoughHole,//14-通用粗孔
        MalePin,//15-销钉
        SmallSP,//16-小拉杆
    }

    //孔 加工类型 -> (数据库) process_Type 
    public enum HoleProcessType
    {
        None = -1,//默认-1
        Sinkhead = 0,//0-沉头孔、带托孔(大孔粗小孔精孔)
        BK_Hole,//1-避空孔、过孔、粗孔通孔
        BlindHole,//2-盲孔、盲精孔
        BlindScrew,//3-盲牙孔
        ThroughHole,//4-通孔、精孔
        ThroughScrew,//5-通牙孔
        D_SinkHead,//6-D托位、与另外的字段使用或暂时不用
        Special,//7-特殊加工要求
        FlatRoughBH,//8-平底粗盲孔
        ConicalRoughBH,//9-尖底粗盲孔（导柱避空盲孔）
        FlatFineBH,//10-平底精盲孔 （导柱精盲孔，用在没有托位的导柱孔）
        ConicalFineBH,//11-尖底精盲孔
        BKBlind //避空&盲
    }


    //UI界面 ComboBox 选项
    public class UIItem
    {
        public string ItemCode { get; set; }
        public string ItemName { get; set; }

        public UIItem(string itemCode, string itemName)
        {
            ItemCode = itemCode;
            ItemName = itemName;
        }
    }

    //框选一副模架时记录 完成标注时入Dic
    public class LbaeldefiInfo
    {
        //投影图中心坐标
        public CAD_Point topViewCP { get; set; }
        //组装图中心坐标
        public CAD_Point AssemViewCP { get; set; }
    }

    //异常日志信息
    public class ErrorLogInfo 
    { 
        public string TempOrderUID { get; set; }
        public string DwgFilePath { get; set; }
        public string ErrorInfo { get; set; }
        public string errorType { get; set; }
        public Boolean InvokeFlag { get; set; } = true;
        public DateTime ErrorCreateTime { get; set; }
        public string jobNumberName { get; set; }
        public string jobNumber { get; set; }
       
    }

    //异常类型
    public enum ErrorType
    {
        NONE,
        ATypeTranCoorError,
        ATypeTranProcessDataError,
        MTypeTranCoorError,
        DBConnectionError,
        ERPHttpStatusError,
        ERPInvokeSuccess,
        BeforeInvokeERPError,
        ERPInteriorError,
        ERPTimeout
    }

    //
    public class FitLineInfo
    {
        public int FirstIndex { get; set; } = -1;
        public int LastIndex { get; set; } = -1;
        public int SortIndex { get; set; } = -1;
        public FullInfoLine targetLine { get; set; } = new FullInfoLine();
        public double MinX { get; set; }
        public double MaxX { get; set; }
    }

    //孔类型
    public enum HoleType
    {
        NONE,//未判定
        GP,
        SP,
        RP,
        TopScrew,
        BootomScrew,
        FangtieScrew,
        epfpScrew,
        RPScrew
    }

    //孔属于零件的哪个部位
    public enum PartType
    {
        NONE,//未判定
        Dim,
        TD,
        BK,
        BushTD,
        BushSize//(BushDim)
    }

    //特殊装配类型
    public enum SpcialAssemType
    {
        Normal,//正常装配
        hrOverbp,//热流道板在底面板上方
    }

    //孔推算中间信息
    public class HoleCir
    {
        public HoleType holeType { get; set; } = HoleType.NONE;
        public CAD_Point CCPoint { get; set; } = new CAD_Point();
        public List<HolePartDInfo> HolePartInfoList { get; set; } = new List<HolePartDInfo>();
        public FPosType fPosType { get; set; } = FPosType.NONE;
        public int cirNum { get; set; } = 0;
        public int orginGetNum { get; set; } = 0;
    }

    public class DWGVObjectIdInfo
    {
        public ObjectId TVObjectId { get; set; } = ObjectId.Null;
        public ObjectId AVObjectId { get; set; } = ObjectId.Null;
    }

    //详细信息
    public class HolePartDInfo
    {
        //部位
        public PartType partType { get; set; } = new PartType();
        //大小
        public double Dim { get; set; }
        public int sortIndex { get; set; } = -1;
    }

    public class CUException : System.Exception
    {
        private ErrorType _errorType { get; set; }
        public CUException(ErrorType errorType)
        {
            _errorType = errorType;
        }

        public ErrorType GetErrorType()
        {
            return _errorType;
        }

        public string ErrorTig()
        {
            Dictionary<ErrorType, string> errorDescriptions = new Dictionary<ErrorType, string>
            {
                { ErrorType.NONE, "未定义异常" },
                { ErrorType.ATypeTranCoorError, "自动模式坐标转换异常" },
                { ErrorType.ATypeTranProcessDataError, "自动模式装配孔加工数据入库异常" },
                { ErrorType.MTypeTranCoorError, "手动模式坐标转换异常" },
                { ErrorType.DBConnectionError, "139.159.178.26 数据库连接异常" },
                { ErrorType.ERPInvokeSuccess, "调用ERP接口成功" },
                { ErrorType.BeforeInvokeERPError, "调用ERP接口前置失败" },
                { ErrorType.ERPHttpStatusError, "调用ERP网络环境异常" },
                { ErrorType.ERPInteriorError, "ERP接口内部处理异常" },
                { ErrorType.ERPTimeout, "ERP接口调用超时" }
        };
            return errorDescriptions[_errorType];
        }
    }

}
